package com.mysoft.gfyx.marketdevelop.mip.dto.TjCustom;

import com.mysoft.framework.common.exception.BusinessLogicException;
import com.mysoft.gfyx.common.util.MyStringUtil;
import com.mysoft.gfyx.marketdevelop.mip.dto.SearchBaseRequestDto;
import lombok.Data;
import org.assertj.core.util.Arrays;

import java.util.ArrayList;
import java.util.Objects;

@Data
public class DeveloperListRequestDto extends SearchBaseRequestDto {
    private int pageNum;
    private int pageSize;
    private String province_code;
    private String city_code;
    private String time_begin;
    private String time_end;
    private String developer_name;
    private String company_type_label;

    private String developer_activity_label;
    private String developer_top_100_label;
    private String is_new_area_expand_label;
    private String is_new_decorate_expand_label;
    private String is_new_land_usage_expand_label;
    private String high_project_customers_label;
    private String is_ycg_certification;
    private String is_ycg_offline_business_connect;
    private String land_type;
    private String developer_province_code;
    private String developer_city_code;

    public static final String FILTER_DEVELOPER_TAGS = "tags_set";

    public static final String FILTER_DEVELOPER_LEVEL_TAG = "company_level_tag";

    public static final String FILTER_COMPANY_TYPE_LABEL = "company_type_label";

    public static final String FILTER_LAND_TYPE = "land_usage";

    protected void setFilterByField(String field, String operatorType, Object value) {
        switch (field) {
            case FILTER_DEVELOPER_LEVEL_TAG:
                if (Objects.equals(operatorType, "in")) {
                    if (value instanceof ArrayList<?>) {
                        for (Object tag : (ArrayList<?>) value) {
                            this.setCompanyLevelTag(tag.toString());
                        }
                    }
                } else {
                    this.setCompanyLevelTag(value.toString());
                }
                break;
            case FILTER_DEVELOPER_TAGS:
                if (Objects.equals(operatorType, "in")) {
                    if (value instanceof ArrayList<?>) {
                        for (Object tag : (ArrayList<?>) value) {
                            this.setTags(tag.toString());
                        }
                    }
                } else {
                    this.setTags(value.toString());
                }
                break;
            case FILTER_COMPANY_TYPE_LABEL:
                if (value instanceof ArrayList) {//如果是数组
                    this.dynamicSetProperty(field, MyStringUtil.TranArrayToStr(operatorType, value));
                } else {//如果是字符串
                    this.dynamicSetProperty(field, value);
                }
                break;
            case FILTER_LAND_TYPE:
                if (value instanceof ArrayList) {//如果是数组
                    this.setLand_type(MyStringUtil.TranArrayToStr(operatorType, value).toString());
                } else {//如果是字符串
                    this.setLand_type(value.toString());
                }
                break;
            default:
                this.dynamicSetProperty(field, MyStringUtil.TranArrayToStr(operatorType, value).toString());
        }
    }

    protected void setTags(String tags)
    {
        switch (tags) {
            case "developer_top_100_label":
                this.setDeveloper_top_100_label("地产百强");
                break;
            case "is_new_decorate_expand_label":
                this.setIs_new_decorate_expand_label("新精装客群");
                break;
            case "is_new_land_usage_expand_label":
                this.setIs_new_land_usage_expand_label("新住宅客群");
                break;
            case "is_new_area_expand_label":
                this.setIs_new_area_expand_label("新区域拓展");
                break;
            case "high_project_customers_label":
                this.setHigh_project_customers_label("高端项目客群");
                break;
            default:
                throw new BusinessLogicException("未定义的标签" + tags);
        }
    }

    protected void setCompanyLevelTag(String tag)
    {
        switch (tag) {
            case "developer_activity_label":
                this.setDeveloper_activity_label("活跃");
                break;
            case "is_ycg_certification":
                this.setIs_ycg_certification("平台认证");
                break;
            case "is_ycg_offline_business_connect":
                this.setIs_ycg_offline_business_connect("供需对接会");
                break;
            default:
                throw new BusinessLogicException("未定义的标签" + tag);
        }
    }
}
